package com.hopu.bean.shop;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class CateHotTop3 implements Serializable, Comparable<CateHotTop3>{

    private String cid;
    private String cname;
    private String type;
    private int view;
    private int cart;
    private int parchase;

    public CateHotTop3(String cid, String cname, String type) {
        this.cid = cid;
        this.cname = cname;
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CateHotTop3 that = (CateHotTop3) o;
        return Objects.equals(cid, that.cid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(cid);
    }


    @Override
    public int compareTo(CateHotTop3 o) {
        if (o.getView() == this.getView()) {
            if (o.getCart() == this.getCart()) {
                return o.getParchase() - this.getParchase();
            } else {
                return o.getParchase() - this.getParchase();
            }
        } else {
            return o.getView() - this.getView();
        }
    }
}
